<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{:config('sys_name')}后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/static/admin/css/global.css" media="all">
    <link rel="stylesheet" href="/static/common/css/font.css" media="all">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <style>

        .layui-form-pane .layui-form-label {
            width: 110px;
            padding: 8px 15px;
            height: 38px;
            line-height: 20px;
            border-width: 0px;
            border-style: none;
            border-radius: 2px 0 0 2px;
            text-align: center;
            background-color: #FBFBFB;
            overflow: hidden;
            box-sizing: border-box;
        }

    </style>
</head>
<body class="skin-<?php if(!empty($_COOKIE['skin'])){echo $_COOKIE['skin'];}else{echo '0';setcookie('skin','0');}?>">

<script type="text/javascript">
    function changeyewu(){
        //重新查找业务员的客户信息
        var custphone = $("#cphone").val();
        $('#cname').val('');
        var url = "{:url('Order/changeyewu')}" + "?cphone="+custphone;
        $.ajax({
        //几个参数需要注意一下
            type: "GET",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: url ,//url
            success: function (result) {
                //console.log(result);//打印服务端返回的数据(调试用)
                //alert("修改成功");
                if (result['msg']['code'] == 0) {
                    $('#checklabel').css('color','red');
                }else{
                    $('#checklabel').css('color','green');
                    $('#cname').val(result['msg']['custname']);
                    $('#pr_user').val(result['msg']['pr_user']);
                    $('#kh_username').val(result['msg']['kh_username']);
                }
                $('#checklabel').html(result['msg']['msg']);
                

            },
            error : function() {
                alert("异常！");
            }
        });
    }
</script>
<div class="admin-main layui-anim layui-anim-upbit" ng-app="hd" ng-controller="ctrl">

    <form class="layui-form layui-form-pane">

        <div class="layui-form-item">
            <label class="layui-form-label">客户手机号</label>
            <div class="layui-input-4">
                <input type="text" id="cphone" onchange="changeyewu()" name="cphone" lay-verify="required" placeholder="请输入手机号码" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-4">
                <label class="" id="checklabel"></label>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户名称</label>
            <div class="layui-input-4">
                <input type="text" readonly='true' id="cname" name="cname" lay-verify="required"  placeholder="请输入客户名称" class="layui-input">
            </div>
        </div>
        {if $Think.session.aid == 1}
        <div class="layui-form-item">
            <label class="layui-form-label">客户负责人</label>
            <div class="layui-input-4">
                <select name="pr_user" id="pr_user">
                    <option value="">请选择客户负责人</option>
                    {volist name='userlist' id='vo'}
                    <option value="{$vo.username}">{$vo.username}</option>
                    {/volist}

                </select>
            </div>
        </div>
        {else /}
        <div class="layui-form-item">
            <label class="layui-form-label">客户负责人</label>
            <div class="layui-input-4">
                <input type="text" readonly='true' id="pr_user" name="pr_user" lay-verify="required" value="{$username}" class="layui-input">
            </div>
        </div>
        {/if}
        <div class="layui-form-item">
            <label class="layui-form-label">金额</label>
            <div class="layui-input-4">
                <input type="text" id="money" name="money"  placeholder="请输入金额" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-4">
                <input type="text" id="kh_username" name="kh_username" value=""  placeholder="请输入用户名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-4">
                <textarea placeholder="请输入备注信息" class="layui-textarea" name="remark"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn"  lay-submit="" lay-filter="submit">提交保存</button>

            </div>
        </div>

    </form>
</div>
{include file="common/foot"/}

<script>
        layui.use(['form', 'layer'], function () {
            var form = layui.form, layer = layui.layer,$= layui.jquery;
            //监听提交
            form.on('submit(submit)', function(data){

                $.post("{:url('Order/add')}",data.field,function (res) {
                    if (res.code == 0){
                        layer.msg(res.msg,{time:2000});
                        layer.close(layer.index);
                        window.parent.location.reload();
                    }else {
                        layer.msg(res.msg,{time:2000});
                    }

                },'json')

                return false;
            });
        });
</script>
</body>
</html>